import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

/* Layout */
// import Layout from "@/layout";
// views/choose-company

export const constantRoutes = [
  {
    path: "/login",
    component: () => import((`@/views/login/index`)),
    hidden: true
  },
  {
    path: "/",
    redirect: "/choose-company"
  },
  {
    path: "/choose-company",
    component: () => import("@/views/choose-company/index"),
    hidden: true
  },
  {
    path: "/404",
    component: () => import("@/views/404"),
    hidden: true
  }
];
// 引用模块路由
import BasicInfoManageRouter from "./modules/BasicInfoManageRouter";
import SystemSettingsRouter from "./modules/SystemSettingsRouter";
import EquipMaintenanceManageRouter from "./modules/EquipMaintenanceManageRouter";
import EquipManageRouter from "./modules/EquipManageRouter";
import PhysicalUnionMonitoringRouter from "./modules/PhysicalUnionMonitoringRouter";
import MonitoringAlarmManagementRouter from "./modules/MonitoringAlarmManagementRouter";
import EquipRepairSupportRouter from "./modules/EquipRepairSupportRouter";
import EquipRepairManageRouter from "./modules/EquipRepairManageRouter";
import EquipInspectionRouter from "./modules/EquipInspectionRouter";
// import SparePartManageRouter from "./modules/SparePartManageRouter";
import StatisticalManageRouter from "./modules/StatisticalManageRouter";
import SystemNotificationManagementRouter from "./modules/SystemNotificationManagementRouter"
export const asyncRoutes = [
  //设备管理
  EquipManageRouter,
  // 设备监控
  PhysicalUnionMonitoringRouter,
  // 设备维修管理
  EquipRepairManageRouter,
  // 设备保养管理
  EquipMaintenanceManageRouter,
  // 设备点检
  EquipInspectionRouter,
  // 备件管理
  // SparePartManageRouter,
  // 设备维修支撑
  EquipRepairSupportRouter,
  // 监测告警管理
  MonitoringAlarmManagementRouter,
  // 统计报表
  StatisticalManageRouter,
  // 基础信息管理
  BasicInfoManageRouter,
  // 系统设置
  SystemSettingsRouter,
  //系统通知管理
  SystemNotificationManagementRouter,
  // {
  //   path: "external-link",
  //   component: Layout,
  //   children: [
  //     {
  //       path: "https://panjiachen.github.io/vue-element-admin-site/#/",
  //       meta: { title: "External Link", icon: "link" }
  //     }
  //   ]
  // },
  // 404 page must be placed at the end !!!
  // { path: "*", redirect: "/404", hidden: true }
];

const createRouter = () =>
  new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
  });

const router = createRouter();

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter();
  router.matcher = newRouter.matcher; // reset router
}

export default router;
